//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.hanlink.dsp.util;

import android.graphics.RectF;
import android.util.Log;

public class DrawFunction {
    private static final double F = 48000;
    private static final double PI = 3.141592653589793D;
    public static final double R = PI * 2;
    private static final double MAX_FREQ = 22000D;
    private static final double MIN_FREQ = 20D;

    public static int getOctType(int filterType, int filterValue) {
        if (filterType == 1) {
            switch (filterValue) {
                case 0:
                    return 0;
                case 1:
                    return 1;
                case 2:
                    return 2;
                case 3:
                    return 3;
                case 4:
                    return 4;
                case 5:
                    return 5;
            }
        } else if (filterType == 0) {
            switch (filterValue) {
                case 0:
                    return 0;
                case 1:
                    return 6;
                case 2:
                    return 7;
                case 3:
                    return 8;
                case 4:
                    return 9;
                case 5:
                    return 10;
            }
        } else if (filterType == 2) {
            switch (filterValue) {
                case 0:
                    return 0;
                case 1:
                    return 11;
                case 2:
                    return -1;
                case 3:
                    return 12;
                case 4:
                    return 13;
                case 5:
                    return 14;
            }
        }
        return -1;
    }
    //oct_type值定义:(BW-巴特沃斯，BS-贝塞尔,LK-宁克)
    //0 BW-06 巴特沃斯6DB (BS-06 贝塞尔)
    //1 BW-12 巴特沃斯12DB
    //2 BW-18 巴特沃斯18DB
    //3 BW-24 巴特沃斯24DB
    //4 BW-36 巴特沃斯36DB
    //5 BW-48 巴特沃斯48DB

    //6 BS-12 贝塞尔12db
    //7 BS-18 贝塞尔18db
    //8 BS-24 贝塞尔24DB
    //9 BS-36 贝塞尔36DB
    //10 BS-48 贝塞尔48DB

    //11 LK-12 宁克12db
    //12 LK-24 宁克24db
    //13 LK-36 宁克36DB
    //14 LK-48 宁克48DB
    public static void cal_point_xover(double freq, byte octType, boolean ishpass, double[] lineXover, boolean var4) {
        if ((freq == 20000 && !ishpass) || (ishpass && freq == 20)) {
            for (int i = 0; i < lineXover.length; ++i) {
                lineXover[i] = 0;
            }
            return;
        }
        Log.e("cal", freq + "," + octType + "+" + ishpass);
        int len = lineXover.length;

        double[] p = new double[4];
        double[] a0 = new double[3];
        double[] a1 = new double[3];
        double[] a2 = new double[3];
        double[] a3 = new double[3];

        double[] b0 = new double[3];
        double[] b1 = new double[3];
        double[] b2 = new double[3];
        double[] b3 = new double[3];

        double[] temp1;
        double[] temp2;
        double[] temp3;
        double[] temp4;
        double w0 = R * freq / F;
        double oc = 2.0D * Math.tan(w0 / 2.0D);
        w0 = oc * Math.tan(w0 / 2.0D);

        //是否高通
        if (!ishpass) {
            switch (octType) {
                case 0: {
                    a0[0] = 1.0D;
                    a0[1] = (oc - 2.0D) / (2.0D + oc);
                    a0[2] = 0.0D;
                    b0[0] = oc / (2.0D + oc);
                    b0[1] = b0[0];
                    b0[2] = 0.0D;
                    mk(freq, a0, b0, lineXover, false);
                }
                break;
                case 1: {
                    p[0] = 1.41421356237309;

                    b0[0] = oc * oc / (4 + 2 * p[0] * oc + oc * oc);
                    b0[1] = 2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = 2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc);
                    a0[2] = (4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc);
                    mk(freq, a0, b0, lineXover, false);
                }
                break;
                case 2: {
                    p[0] = 1;
                    p[1] = 1;

                    b0[0] = oc * oc / (4 + 2 * p[0] * oc + oc * oc);
                    b0[1] = 2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = 2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc);
                    a0[2] = (4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc);

                    b1[0] = p[1] * oc / (2 + p[1] * oc);
                    b1[1] = b1[0];
                    b1[2] = 0;
                    a1[0] = 1;
                    a1[1] = (p[1] * oc - 2) / (2 + p[1] * oc);
                    a1[2] = 0;

                    temp1 = new double[len];
                    temp2 = new double[len];

                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);
                    for (int i = 0; i < len; i++) {
                        lineXover[i] = (temp1[i] + temp2[i]);
                    }
                }
                break;
                case 3: {
                    p[0] = 0.76536686473018;
                    p[1] = 1.84775906502257;

                    b0[0] = oc * oc / (4 + 2 * p[0] * oc + oc * oc);
                    b0[1] = 2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = 2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc);
                    a0[2] = (4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc);


                    b1[0] = oc * oc / (4 + 2 * p[1] * oc + oc * oc);
                    b1[1] = 2 * b1[0];
                    b1[2] = b1[0];
                    a1[0] = 1;
                    a1[1] = 2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc);
                    a1[2] = (4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc);

                    temp1 = new double[len];
                    temp2 = new double[len];

                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = (temp1[i] + temp2[i]);
                    }
                }
                break;
                case 4: {
                    p[0] = 0.51763809020504;
                    p[1] = 1.41421356237309;
                    p[2] = 1.93185165257814;

                    b0[0] = oc * oc / (4 + 2 * p[0] * oc + oc * oc);
                    b0[1] = 2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = 2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc);
                    a0[2] = (4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc);

                    b1[0] = oc * oc / (4 + 2 * p[1] * oc + oc * oc);
                    b1[1] = 2 * b1[0];
                    b1[2] = b1[0];
                    a1[0] = 1;
                    a1[1] = 2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc);
                    a1[2] = (4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc);

                    b2[0] = oc * oc / (4 + 2 * p[2] * oc + oc * oc);
                    b2[1] = 2 * b2[0];
                    b2[2] = b2[0];
                    a2[0] = 1;
                    a2[1] = 2 * (oc * oc - 4) / (4 + 2 * p[2] * oc + oc * oc);
                    a2[2] = (4 - 2 * p[2] * oc + oc * oc) / (4 + 2 * p[2] * oc + oc * oc);

                    temp1 = new double[len];
                    temp2 = new double[len];
                    temp3 = new double[len];

                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);
                    mk(freq, a2, b2, temp3, false);
                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i] + temp3[i];
                    }
                }
                break;
                case 5: {
                    p[0] = 0.39018064403226;
                    p[1] = 1.11114046603920;
                    p[2] = 1.66293922460509;
                    p[3] = 1.96157056080646;

                    b0[0] = oc * oc / (4 + 2 * p[0] * oc + oc * oc);
                    b0[1] = 2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = 2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc);
                    a0[2] = (4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc);

                    b1[0] = oc * oc / (4 + 2 * p[1] * oc + oc * oc);
                    b1[1] = 2 * b1[0];
                    b1[2] = b1[0];
                    a1[0] = 1;
                    a1[1] = 2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc);
                    a1[2] = (4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc);

                    b2[0] = oc * oc / (4 + 2 * p[2] * oc + oc * oc);
                    b2[1] = 2 * b2[0];
                    b2[2] = b2[0];
                    a2[0] = 1;
                    a2[1] = 2 * (oc * oc - 4) / (4 + 2 * p[2] * oc + oc * oc);
                    a2[2] = (4 - 2 * p[2] * oc + oc * oc) / (4 + 2 * p[2] * oc + oc * oc);

                    b3[0] = oc * oc / (4 + 2 * p[3] * oc + oc * oc);
                    b3[1] = 2 * b3[0];
                    b3[2] = b3[0];
                    a3[0] = 1;
                    a3[1] = 2 * (oc * oc - 4) / (4 + 2 * p[3] * oc + oc * oc);
                    a3[2] = (4 - 2 * p[3] * oc + oc * oc) / (4 + 2 * p[3] * oc + oc * oc);

                    temp1 = new double[len];
                    temp2 = new double[len];
                    temp3 = new double[len];
                    temp4 = new double[len];

                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);
                    mk(freq, a2, b2, temp3, false);
                    mk(freq, a3, b3, temp4, false);
                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i] + temp3[i] + temp4[i];
                    }
                }
                break;
                case 6: {
                    p[0] = 1.73205080756888;

                    b0[0] = oc * oc / (4 + 2 * p[0] * oc + oc * oc);
                    b0[1] = 2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = 2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc);
                    a0[2] = (4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc);

                    mk(freq, a0, b0, lineXover, false);
                }
                break;
                case 7: {
                    p[0] = 1.49128077169616;
                    p[1] = 0.94160002653321;

                    b0[0] = oc * oc / (4 + 2 * p[0] * oc + oc * oc);
                    b0[1] = 2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = 2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc);
                    a0[2] = (4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc);

                    b1[0] = p[1] * oc / (2 + p[1] * oc);
                    b1[1] = b1[0];
                    b1[2] = 0;
                    a1[0] = 1;
                    a1[1] = (p[1] * oc - 2) / (2 + p[1] * oc);
                    a1[2] = 0;


                    temp1 = new double[len];
                    temp2 = new double[len];

                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i];
                    }
                }
                break;
                case 8: {
                    p[0] = 1.31442234334377;
                    p[1] = 1.80951759357649;

                    b0[0] = oc * oc / (4 + 2 * p[0] * oc + oc * oc);
                    b0[1] = 2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = 2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc);
                    a0[2] = (4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc);

                    b1[0] = oc * oc / (4 + 2 * p[1] * oc + oc * oc);
                    b1[1] = 2 * b1[0];
                    b1[2] = b1[0];
                    a1[0] = 1;
                    a1[1] = 2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc);
                    a1[2] = (4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc);


                    temp1 = new double[len];
                    temp2 = new double[len];

                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i];
                    }
                }
                break;
                case 9: {
                    p[0] = 1.81878136609445;
                    p[1] = 1.59930837166566;
                    p[2] = 1.07710536333862;

                    b0[0] = oc * oc / (4 + 2 * p[0] * oc + oc * oc);
                    b0[1] = 2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = 2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc);
                    a0[2] = (4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc);

                    b1[0] = oc * oc / (4 + 2 * p[1] * oc + oc * oc);
                    b1[1] = 2 * b1[0];
                    b1[2] = b1[0];
                    a1[0] = 1;
                    a1[1] = 2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc);
                    a1[2] = (4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc);

                    b2[0] = oc * oc / (4 + 2 * p[2] * oc + oc * oc);
                    b2[1] = 2 * b2[0];
                    b2[2] = b2[0];
                    a2[0] = 1;
                    a2[1] = 2 * (oc * oc - 4) / (4 + 2 * p[2] * oc + oc * oc);
                    a2[2] = (4 - 2 * p[2] * oc + oc * oc) / (4 + 2 * p[2] * oc + oc * oc);

                    temp1 = new double[len];
                    temp2 = new double[len];
                    temp3 = new double[len];

                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);
                    mk(freq, a2, b2, temp3, false);
                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i] + temp3[i];
                    }
                }
                break;
                case 10: {
                    p[0] = 1.81936630933058;
                    p[1] = 1.69465016047187;
                    p[2] = 1.42227636169708;
                    p[3] = 0.92434808250642;

                    b0[0] = oc * oc / (4 + 2 * p[0] * oc + oc * oc);
                    b0[1] = 2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = 2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc);
                    a0[2] = (4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc);

                    b1[0] = oc * oc / (4 + 2 * p[1] * oc + oc * oc);
                    b1[1] = 2 * b1[0];
                    b1[2] = b1[0];
                    a1[0] = 1;
                    a1[1] = 2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc);
                    a1[2] = (4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc);

                    b2[0] = oc * oc / (4 + 2 * p[2] * oc + oc * oc);
                    b2[1] = 2 * b2[0];
                    b2[2] = b2[0];
                    a2[0] = 1;
                    a2[1] = 2 * (oc * oc - 4) / (4 + 2 * p[2] * oc + oc * oc);
                    a2[2] = (4 - 2 * p[2] * oc + oc * oc) / (4 + 2 * p[2] * oc + oc * oc);

                    b3[0] = oc * oc / (4 + 2 * p[3] * oc + oc * oc);
                    b3[1] = 2 * b3[0];
                    b3[2] = b3[0];
                    a3[0] = 1;
                    a3[1] = 2 * (oc * oc - 4) / (4 + 2 * p[3] * oc + oc * oc);
                    a3[2] = (4 - 2 * p[3] * oc + oc * oc) / (4 + 2 * p[3] * oc + oc * oc);


                    temp1 = new double[len];
                    temp2 = new double[len];
                    temp3 = new double[len];
                    temp4 = new double[len];
                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);
                    mk(freq, a2, b2, temp3, false);
                    mk(freq, a3, b3, temp4, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i] + temp3[i] + temp4[i];
                    }
                }
                break;
                case 11: {
                    b0[0] = oc / (2 + oc);
                    b0[1] = b0[0];
                    b0[2] = 0;
                    a0[0] = 1;
                    a0[1] = (oc - 2) / (2 + oc);
                    a0[2] = 0;

                    b1[0] = b0[0];
                    b1[1] = b0[1];
                    b1[2] = b0[2];
                    a1[0] = a0[0];
                    a1[1] = a0[1];
                    a1[2] = a0[2];

                    temp1 = new double[len];
                    temp2 = new double[len];


                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i];
                    }
                }
                break;
                case 12: {
                    p[0] = 1.41421356237309;

                    b0[0] = oc * oc / (4 + 2 * p[0] * oc + oc * oc);
                    b0[1] = 2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = 2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc);
                    a0[2] = (4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc);

                    b1[0] = b0[0];
                    b1[1] = b0[1];
                    b1[2] = b0[2];
                    a1[0] = a0[0];
                    a1[1] = a0[1];
                    a1[2] = a0[2];


                    temp1 = new double[len];
                    temp2 = new double[len];

                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);


                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i];
                    }
                }
                break;
                case 13: {
                    p[0] = 0.76536686473018;
                    p[1] = 1.84775906502257;
                    p[2] = 1.41421356237309;

                    b0[0] = oc * oc / (4 + 2 * p[0] * oc + oc * oc);
                    b0[1] = 2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = 2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc);
                    a0[2] = (4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc);

                    b1[0] = oc * oc / (4 + 2 * p[1] * oc + oc * oc);
                    b1[1] = 2 * b1[0];
                    b1[2] = b1[0];
                    a1[0] = 1;
                    a1[1] = 2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc);
                    a1[2] = (4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc);

                    b2[0] = oc * oc / (4 + 2 * p[2] * oc + oc * oc);
                    b2[1] = 2 * b2[0];
                    b2[2] = b2[0];
                    a2[0] = 1;
                    a2[1] = 2 * (oc * oc - 4) / (4 + 2 * p[2] * oc + oc * oc);
                    a2[2] = (4 - 2 * p[2] * oc + oc * oc) / (4 + 2 * p[2] * oc + oc * oc);

                    temp1 = new double[len];
                    temp2 = new double[len];
                    temp3 = new double[len];

                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);
                    mk(freq, a2, b2, temp3, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i] + temp3[i];
                    }
                }
                break;
                case 14: {
                    p[0] = 0.76536686473018;
                    p[1] = 1.84775906502257;

                    b0[0] = oc * oc / (4 + 2 * p[0] * oc + oc * oc);
                    b0[1] = 2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = 2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc);
                    a0[2] = (4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc);

                    b1[0] = oc * oc / (4 + 2 * p[1] * oc + oc * oc);
                    b1[1] = 2 * b1[0];
                    b1[2] = b1[0];
                    a1[0] = 1;
                    a1[1] = 2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc);
                    a1[2] = (4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc);

                    b2[0] = b0[0];
                    b2[1] = b0[1];
                    b2[2] = b0[2];
                    a2[0] = a0[0];
                    a2[1] = a0[1];
                    a2[2] = a0[2];

                    b3[0] = b1[0];
                    b3[1] = b1[1];
                    b3[2] = b1[2];
                    a3[0] = a1[0];
                    a3[1] = a1[1];
                    a3[2] = a1[2];

                    temp1 = new double[len];
                    temp2 = new double[len];
                    temp3 = new double[len];
                    temp4 = new double[len];

                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);
                    mk(freq, a2, b2, temp3, false);
                    mk(freq, a3, b3, temp4, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i] + temp3[i] + temp4[i];
                    }
                }
                break;
            }
        } else {
            switch (octType) {
                case 0://BW-6
                {//BW-06
                    p[0] = 1;

                    b0[0] = oc / (w0 + p[0] * oc);
                    b0[1] = -b0[0];
                    b0[2] = 0;
                    a0[0] = 1;
                    a0[1] = -(p[0] * oc - w0) / (w0 + p[0] * oc);
                    a0[2] = 0;
                    mk(freq, a0, b0, lineXover, false);
                } break;
                case 1://BW-12
                {
                    p[0] = 1.41421356237309;

                    b0[0] = oc * oc / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    b0[1] = -2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    a0[2] = (w0 * w0 - w0 * p[0] * oc + oc * oc) / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    mk(freq, a0, b0, lineXover, false);
                } break;
                case 2://BW-18
                {
                    p[0] = 1;
                    p[1] = 1;

                    b0[0] = oc * oc / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    b0[1] = -2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    a0[2] = (w0 * w0 - w0 * p[0] * oc + oc * oc) / (w0 * w0 + w0 * p[0] * oc + oc * oc);

                    b1[0] = p[1] * oc / (w0 + p[1] * oc);
                    b1[1] = -b1[0];
                    b1[2] = 0;
                    a1[0] = 1;
                    a1[1] = -(p[1] * oc - w0) / (w0 + p[1] * oc);
                    a1[2] = 0;

                    temp1 = new double[len];
                    temp2 = new double[len];

                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = (temp1[i] + temp2[i]);
                    }

                } break;
                case 3://BW-24
                {
                    p[0] = 0.76536686473018;
                    p[1] = 1.84775906502257;

                    b0[0] = oc * oc / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    b0[1] = -2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    a0[2] = (w0 * w0 - w0 * p[0] * oc + oc * oc) / (w0 * w0 + w0 * p[0] * oc + oc * oc);

                    b1[0] = oc * oc / (w0 * w0 + w0 * p[1] * oc + oc * oc);
                    b1[1] = -2 * b1[0];
                    b1[2] = b1[0];
                    a1[0] = 1;
                    a1[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[1] * oc + oc * oc);
                    a1[2] = (w0 * w0 - w0 * p[1] * oc + oc * oc) / (w0 * w0 + w0 * p[1] * oc + oc * oc);

                    temp1 = new double[len];
                    temp2 = new double[len];
                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i];
                    }
                }  break;
                case 4://BW-36
                {
                    p[0] = 0.51763809020504;
                    p[1] = 1.41421356237309;
                    p[2] = 1.93185165257814;

                    b0[0] = oc * oc / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    b0[1] = -2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    a0[2] = (w0 * w0 - w0 * p[0] * oc + oc * oc) / (w0 * w0 + w0 * p[0] * oc + oc * oc);

                    b1[0] = oc * oc / (w0 * w0 + w0 * p[1] * oc + oc * oc);
                    b1[1] = -2 * b1[0];
                    b1[2] = b1[0];
                    a1[0] = 1;
                    a1[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[1] * oc + oc * oc);
                    a1[2] = (w0 * w0 - w0 * p[1] * oc + oc * oc) / (w0 * w0 + w0 * p[1] * oc + oc * oc);

                    b2[0] = oc * oc / (w0 * w0 + w0 * p[2] * oc + oc * oc);
                    b2[1] = -2 * b2[0];
                    b2[2] = b2[0];
                    a2[0] = 1;
                    a2[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[2] * oc + oc * oc);
                    a2[2] = (w0 * w0 - w0 * p[2] * oc + oc * oc) / (w0 * w0 + w0 * p[2] * oc + oc * oc);

                    temp1 = new double[len];
                    temp2 = new double[len];
                    temp3 = new double[len];
                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);
                    mk(freq, a2, b2, temp3, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i] + temp3[i];
                    }
                } break;
                case 5://BW-48
                {
                    p[0] = 0.39018064403226;
                    p[1] = 1.11114046603920;
                    p[2] = 1.66293922460509;
                    p[3] = 1.96157056080646;

                    b0[0] = oc * oc / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    b0[1] = -2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    a0[2] = (w0 * w0 - w0 * p[0] * oc + oc * oc) / (w0 * w0 + w0 * p[0] * oc + oc * oc);

                    b1[0] = oc * oc / (w0 * w0 + w0 * p[1] * oc + oc * oc);
                    b1[1] = -2 * b1[0];
                    b1[2] = b1[0];
                    a1[0] = 1;
                    a1[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[1] * oc + oc * oc);
                    a1[2] = (w0 * w0 - w0 * p[1] * oc + oc * oc) / (w0 * w0 + w0 * p[1] * oc + oc * oc);

                    b2[0] = oc * oc / (w0 * w0 + w0 * p[2] * oc + oc * oc);
                    b2[1] = -2 * b2[0];
                    b2[2] = b2[0];
                    a2[0] = 1;
                    a2[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[2] * oc + oc * oc);
                    a2[2] = (w0 * w0 - w0 * p[2] * oc + oc * oc) / (w0 * w0 + w0 * p[2] * oc + oc * oc);

                    b3[0] = oc * oc / (w0 * w0 + w0 * p[3] * oc + oc * oc);
                    b3[1] = -2 * b3[0];
                    b3[2] = b3[0];
                    a3[0] = 1;
                    a3[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[3] * oc + oc * oc);
                    a3[2] = (w0 * w0 - w0 * p[3] * oc + oc * oc) / (w0 * w0 + w0 * p[3] * oc + oc * oc);

                    temp1 = new double[len];
                    temp2 = new double[len];
                    temp3 = new double[len];
                    temp4 = new double[len];
                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);
                    mk(freq, a2, b2, temp3, false);
                    mk(freq, a3, b3, temp4, false);


                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i] + temp3[i] + temp4[i];
                    }
                } break;
                case 6://BS-12
                {
                    p[0] = 1.73205080756888;

                    b0[0] = oc * oc / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    b0[1] = -2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    a0[2] = (w0 * w0 - w0 * p[0] * oc + oc * oc) / (w0 * w0 + w0 * p[0] * oc + oc * oc);

                    mk(freq, a0, b0, lineXover, false);
                } break;
                case 7://BS-18
                {
                    p[0] = 1.49128077169616;
                    p[1] = 0.94160002653321;

                    b0[0] = oc * oc / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    b0[1] = -2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    a0[2] = (w0 * w0 - w0 * p[0] * oc + oc * oc) / (w0 * w0 + w0 * p[0] * oc + oc * oc);

                    b1[0] = p[1] * oc / (w0 + p[1] * oc);
                    b1[1] = -b1[0];
                    b1[2] = 0;
                    a1[0] = 1;
                    a1[1] = -(p[1] * oc - w0) / (w0 + p[1] * oc);
                    a1[2] = 0;

                    temp1 = new double[len];
                    temp2 = new double[len];

                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = (temp1[i] + temp2[i]);
                    }
                } break;
                case 8://BS-24
                {
                    p[0] = 1.31442234334377;
                    p[1] = 1.80951759357649;

                    b0[0] = oc * oc / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    b0[1] = -2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    a0[2] = (w0 * w0 - w0 * p[0] * oc + oc * oc) / (w0 * w0 + w0 * p[0] * oc + oc * oc);

                    b1[0] = oc * oc / (w0 * w0 + w0 * p[1] * oc + oc * oc);
                    b1[1] = -2 * b1[0];
                    b1[2] = b1[0];
                    a1[0] = 1;
                    a1[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[1] * oc + oc * oc);
                    a1[2] = (w0 * w0 - w0 * p[1] * oc + oc * oc) / (w0 * w0 + w0 * p[1] * oc + oc * oc);

                    temp1 = new double[len];
                    temp2 = new double[len];

                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = (temp1[i] + temp2[i]);
                    }

                } break;
                case 9://BS-36
                {
                    p[0] = 1.81878136609445;
                    p[1] = 1.59930837166566;
                    p[2] = 1.07710536333862;

                    b0[0] = oc * oc / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    b0[1] = -2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    a0[2] = (w0 * w0 - w0 * p[0] * oc + oc * oc) / (w0 * w0 + w0 * p[0] * oc + oc * oc);

                    b1[0] = oc * oc / (w0 * w0 + w0 * p[1] * oc + oc * oc);
                    b1[1] = -2 * b1[0];
                    b1[2] = b1[0];
                    a1[0] = 1;
                    a1[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[1] * oc + oc * oc);
                    a1[2] = (w0 * w0 - w0 * p[1] * oc + oc * oc) / (w0 * w0 + w0 * p[1] * oc + oc * oc);

                    b2[0] = oc * oc / (w0 * w0 + w0 * p[2] * oc + oc * oc);
                    b2[1] = -2 * b2[0];
                    b2[2] = b2[0];
                    a2[0] = 1;
                    a2[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[2] * oc + oc * oc);
                    a2[2] = (w0 * w0 - w0 * p[2] * oc + oc * oc) / (w0 * w0 + w0 * p[2] * oc + oc * oc);

                    temp1 = new double[len];
                    temp2 = new double[len];
                    temp3 = new double[len];
                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);
                    mk(freq, a2, b2, temp3, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = (temp1[i] + temp2[i] + temp3[i]);
                    }
                } break;
                case 10://BS-48
                {
                    p[0] = 1.81936630933058;
                    p[1] = 1.69465016047187;
                    p[2] = 1.42227636169708;
                    p[3] = 0.92434808250642;

                    b0[0] = oc * oc / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    b0[1] = -2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    a0[2] = (w0 * w0 - w0 * p[0] * oc + oc * oc) / (w0 * w0 + w0 * p[0] * oc + oc * oc);

                    b1[0] = oc * oc / (w0 * w0 + w0 * p[1] * oc + oc * oc);
                    b1[1] = -2 * b1[0];
                    b1[2] = b1[0];
                    a1[0] = 1;
                    a1[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[1] * oc + oc * oc);
                    a1[2] = (w0 * w0 - w0 * p[1] * oc + oc * oc) / (w0 * w0 + w0 * p[1] * oc + oc * oc);

                    b2[0] = oc * oc / (w0 * w0 + w0 * p[2] * oc + oc * oc);
                    b2[1] = -2 * b2[0];
                    b2[2] = b2[0];
                    a2[0] = 1;
                    a2[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[2] * oc + oc * oc);
                    a2[2] = (w0 * w0 - w0 * p[2] * oc + oc * oc) / (w0 * w0 + w0 * p[2] * oc + oc * oc);

                    b3[0] = oc * oc / (w0 * w0 + w0 * p[3] * oc + oc * oc);
                    b3[1] = -2 * b3[0];
                    b3[2] = b3[0];
                    a3[0] = 1;
                    a3[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[3] * oc + oc * oc);
                    a3[2] = (w0 * w0 - w0 * p[3] * oc + oc * oc) / (w0 * w0 + w0 * p[3] * oc + oc * oc);

                    temp1 = new double[len];
                    temp2 = new double[len];
                    temp3 = new double[len];
                    temp4 = new double[len];
                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);
                    mk(freq, a2, b2, temp3, false);
                    mk(freq, a3, b3, temp4, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = (temp1[i] + temp2[i] + temp3[i] + temp4[i]);
                    }

                } break;
                case 11://LK-12
                {
                    b0[0] = oc / (w0 + oc);
                    b0[1] = -b0[0];
                    b0[2] = 0;
                    a0[0] = 1;
                    a0[1] = -(oc - w0) / (w0 + oc);
                    a0[2] = 0;

                    b1[0] = b0[0];
                    b1[1] = b0[1];
                    b1[2] = b0[2];
                    a1[0] = a0[0];
                    a1[1] = a0[1];
                    a1[2] = a0[2];

                    temp1 = new double[len];
                    temp2 = new double[len];
                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i];
                    }

                } break;
                case 12: //LK-24
                {
                    p[0] = 1.41421356237309;

                    b0[0] = oc * oc / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    b0[1] = -2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    a0[2] = (w0 * w0 - w0 * p[0] * oc + oc * oc) / (w0 * w0 + w0 * p[0] * oc + oc * oc);

                    b1[0] = b0[0];
                    b1[1] = b0[1];
                    b1[2] = b0[2];
                    a1[0] = a0[0];
                    a1[1] = a0[1];
                    a1[2] = a0[2];

                    temp1 = new double[len];
                    temp2 = new double[len];
                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i];
                    }
                } break;
                case 13://LK-36
                {
                    p[0] = 0.76536686473018;
                    p[1] = 1.84775906502257;
                    p[2] = 1.41421356237309;

                    b0[0] = oc * oc / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    b0[1] = -2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    a0[2] = (w0 * w0 - w0 * p[0] * oc + oc * oc) / (w0 * w0 + w0 * p[0] * oc + oc * oc);

                    b1[0] = oc * oc / (w0 * w0 + w0 * p[1] * oc + oc * oc);
                    b1[1] = -2 * b1[0];
                    b1[2] = b1[0];
                    a1[0] = 1;
                    a1[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[1] * oc + oc * oc);
                    a1[2] = (w0 * w0 - w0 * p[1] * oc + oc * oc) / (w0 * w0 + w0 * p[1] * oc + oc * oc);

                    b2[0] = oc * oc / (w0 * w0 + w0 * p[2] * oc + oc * oc);
                    b2[1] = -2 * b2[0];
                    b2[2] = b2[0];
                    a2[0] = 1;
                    a2[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[2] * oc + oc * oc);
                    a2[2] = (w0 * w0 - w0 * p[2] * oc + oc * oc) / (w0 * w0 + w0 * p[2] * oc + oc * oc);

                    temp1 = new double[len];
                    temp2 = new double[len];
                    temp3 = new double[len];
                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);
                    mk(freq, a2, b2, temp3, false);

                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i] + temp3[i];
                    }

                }  break;
                case 14://LK-48
                {
                    p[0] = 0.76536686473018;
                    p[1] = 1.84775906502257;

                    b0[0] = oc * oc / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    b0[1] = -2 * b0[0];
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[0] * oc + oc * oc);
                    a0[2] = (w0 * w0 - w0 * p[0] * oc + oc * oc) / (w0 * w0 + w0 * p[0] * oc + oc * oc);

                    b1[0] = oc * oc / (w0 * w0 + w0 * p[1] * oc + oc * oc);
                    b1[1] = -2 * b1[0];
                    b1[2] = b1[0];
                    a1[0] = 1;
                    a1[1] = -2 * (oc * oc - w0 * w0) / (w0 * w0 + w0 * p[1] * oc + oc * oc);
                    a1[2] = (w0 * w0 - w0 * p[1] * oc + oc * oc) / (w0 * w0 + w0 * p[1] * oc + oc * oc);

                    b2[0] = b0[0];
                    b2[1] = b0[1];
                    b2[2] = b0[2];
                    a2[0] = a0[0];
                    a2[1] = a0[1];
                    a2[2] = a0[2];

                    b3[0] = b1[0];
                    b3[1] = b1[1];
                    b3[2] = b1[2];
                    a3[0] = a1[0];
                    a3[1] = a1[1];
                    a3[2] = a1[2];


                    temp1 = new double[len];
                    temp2 = new double[len];
                    temp3 = new double[len];
                    temp4 = new double[len];
                    mk(freq, a0, b0, temp1, false);
                    mk(freq, a1, b1, temp2, false);
                    mk(freq, a2, b2, temp3, false);
                    mk(freq, a3, b3, temp4, false);
                    for (int i = 0; i < len; i++) {
                        lineXover[i] = temp1[i] + temp2[i] + temp3[i] + temp4[i];
                    }
                }  break;


                default:
                    break;
            }
        }

        temp1 = null;
        temp2 = null;
        temp3 = null;
        temp4 = null;
    }

    public static void cal_rect(RectF var0, int var1, float var2, short var3, int var4, int var5, int var6, int var7, int var8) {
        var4 = fc2int(var4, 0, var3);
        var5 = (int) ((1.0F - var2 / (float) var8) * (float) var5 / 2.0F);
        var0.left = (float) (var4 + var6 - var1);
        var0.top = (float) (var5 - var1 + var7);
        var0.right = var0.left + (float) (var1 * 2);
        var0.bottom = var0.top + (float) (var1 * 2);
    }

    public static final void double2float(float var0, int var1, double[] var2, int var3, float[] var4) {
        for (int var5 = 0; var5 < var2.length; ++var5) {
            var4[var5 * 4] = (float) (var3 + var5);
            var4[var5 * 4 + 1] = (float) (var2[var5] * (double) var0 + (double) var1);
        }

        for (var1 = 0; var1 < var2.length - 1; ++var1) {
            var4[var1 * 4 + 2] = var4[(var1 + 1) * 4];
            var4[var1 * 4 + 3] = var4[(var1 + 1) * 4 + 1];
        }

        var4[var1 * 4 + 2] = var4[var1 * 4] + 1.0F;
        var4[var1 * 4 + 3] = var4[var1 * 4 + 1];
    }

    public static final int fc2int(int var0, int var1, short var2) {
        double var3 = (double) var2;
        double var5 = (double) var0;
        return (int) ((Math.log10(var3) - Math.log10(MIN_FREQ)) / (Math.log10(MAX_FREQ) - Math.log10(MIN_FREQ)) * (var5 - (double) var1) + (double) var1);
    }

    public static final short int2fc(int var0, int var1, int var2) {
        double var3 = (double) var2;
        double var5 = (double) var0;
        return (short) ((int) Math.pow(10.0D, (var3 - (double) var1) / (var5 - (double) var1) * (Math.log10(MAX_FREQ) - Math.log10(MIN_FREQ)) + Math.log10(MIN_FREQ)));
    }

    public static final double int2fc2(int l, int a, int index) {
        double len = (double) l;
        double i = (double) index;
        return Math.pow(10.0D, (i - (double) a) / (len - (double) a) * (Math.log10(MAX_FREQ) - Math.log10(MIN_FREQ)) + Math.log10(MIN_FREQ));
    }

    private static final void mk(double f, double[] a, double[] b, double[] lineXover, boolean ispol) {
        int length = lineXover.length;
        double x, w, u, v, s, t, h;
        if (ispol) {
            for (int i = 0; i < length; ++i) {
                x = int2fc2(length, 0, i);
                w = R * x / F;

                u = b[0] + b[1] * Math.cos(w) + b[2] * Math.cos(2.0D * w);
                v = -b[1] * Math.sin(w) - b[2] * Math.sin(2.0D * w);
                s = a[0] + a[1] * Math.cos(w) + a[2] * Math.cos(2.0D * w);
                t = -a[1] * Math.sin(w) - a[2] * Math.sin(2.0D * w);

                double Im = (s * v - t * u);
                double Re = (s * u + t * v);

                h = 180 * Math.atan2(Im, Re) / PI;
                lineXover[i] = h;
            }
        } else {
            for (int i = 0; i < length; ++i) {
                x = int2fc2(length, 0, i);
                w = R * x / F;

                u = b[0] + b[1] * Math.cos(w) + b[2] * Math.cos(2.0D * w);
                v = -b[1] * Math.sin(w) - b[2] * Math.sin(2.0D * w);
                s = a[0] + a[1] * Math.cos(w) + a[2] * Math.cos(2.0D * w);
                t = -a[1] * Math.sin(w) - a[2] * Math.sin(2.0D * w);

                h = Math.sqrt((Math.pow(u, 2) + Math.pow(v, 2)) / (Math.pow(s, 2) + Math.pow(t, 2)));

                lineXover[i] = Math.log10(h);
            }
        }

    }
}
